
#include <gl/freeglut.h>


class wcPt3D
{
private:
	GLfloat x, y, z;
public:
	/* Default ctor:
	 */
	wcPt3D() : x(0), y(0), z(0) {
	}

	void setCoords(GLfloat xCoord, GLfloat yCoord, GLfloat zCoord) {
		x = xCoord;
		y = yCoord;
		z = zCoord;
	}

	GLfloat getx() const {
		return x;
	}
	GLfloat gety() const {
		return y;
	}
	GLfloat getz() const {
		return z;
	}
};
typedef float Matrix4x4[4][4];

GLint winWidth = 600, winHeight = 400;

void init()
{
	glClearColor(1.0, 1.0, 1.0, 1.0);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	gluOrtho2D(0.0, winWidth, 0.0, winHeight);
}

void matrix4x4SetIdentity(Matrix4x4 matIdent4x4)
{
	GLint row, col;

	for (row = 0; row < 4; row++)
		for (col = 0; col < 4; col++)
			matIdent4x4[row][col] = (row == col);
}

void scale3D(GLfloat sx, GLfloat sy, GLfloat sz, wcPt3D fixedPt)
{
	Matrix4x4 matScale3D;

	/* Initialize scaling matrix to identity. */
	matrix4x4SetIdentity(matScale3D);
	matScale3D[0][0] = sx;
	matScale3D[0][3] = (1 - sx) * fixedPt.getx();
	matScale3D[1][1] = sy;
	matScale3D[1][3] = (1 - sy) * fixedPt.gety();
	matScale3D[2][2] = sz;
	matScale3D[2][3] = (1 - sz) * fixedPt.getz();
}

void display()
{
	glClear(GL_COLOR_BUFFER_BIT);
	glColor3f(0.0, 0.0, 0.0);

	glPushMatrix();
	glPopMatrix();
	glFlush();
}

void reshape(int w, int h)
{
	glClearColor(1.0, 1.0, 1.0, 1.0);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	gluOrtho2D(0.0, w, 0.0, h);
}

int main(int argc, char* argv[])
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
	glutInitWindowPosition(10, 50);
	glutInitWindowSize(winWidth, winHeight);

	init();
	glutCreateWindow("3D Scale");
	glutDisplayFunc(display);
	glutReshapeFunc(reshape);
	
	glutMainLoop();
	return 0;
}